import {
  exportUrl,
  downloadTemplateUrl,
  importUrl,
} from "@/api/process/mesTechnologyCharacteristic";
import { exportExcel } from "@/utils/judge";
import excelUpload from "@/components/excel-upload/excelUpload";
// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"), // "导出",
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl,
    //auth: "auth:xx:export", //权限字段
  },
  {
    name: $i18n.t("common.add"), //"新增",
    type: "primary",
    icon: "el-icon-circle-plus-outline",
    handleName: "add", // 点击时返回的标识
    // auth: "auth:user:add", //权限字段
  },

  {
    name: $i18n.t("common.delete"), //""删除",
    type: "danger",
    icon: "el-icon-delete",
    handleName: "delete",
    isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
    // auth: "auth:user:delete", //权限字段
  },

  {
    // 导入文件
    render: (h, scope) => {
      // scope列表上选择的数据
      const uploadUrl = importUrl;
      return (
        <excelUpload
          action={uploadUrl}
          on={{
            handleUploadError: (err) => {
              // 失败的回调
              console.log(err);
            },
            handleUploadSuccess: (res) => {
              //   _this.$refs.eleTable.handleReset();
              _this.subRefresh();
              //成功 的回调
            },
          }}
        />
      );
    },
  },
  {
    name: $i18n.t("common.copy"), //" "复制",
    type: "primary",
    icon: "el-icon-document-copy",
    handleName: "copy", // 点击时返回的标识
    // auth: "auth:user:add", //权限字段
  },
  {
    name: $i18n.t("common.downloadTemplate"),
    type: "success",
    icon: "el-icon-download",
    handleName: "exportExcel", // 点击时返回的标识
  },
];
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    propCode: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.materialCode"),
    },
    propName: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.materialName"),
    },
    characterCode: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.characterCode"),
    },
    characterName: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.characterName"),
    },
  },
};
// 表格的行内操作
export const rowConfig = [
  {
    name: $i18n.t("common.edit"), //"修改",
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit", // 点击时返回的标识
    // auth: "auth:user:edit", //权限字段
  },
  {
    name: $i18n.t("common.details"), //"详情",
    type: "info",
    class: "row-btn-info",
    handleName: "info", // 点击时返回的标识
  },
];

// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  // 表单是否可编辑
  disabled: true,
  // 是否显示提交按钮
  isShowSubmitBtn: true,
  formDesc: {
    techCode: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.techCode"),
      layout: 12,
      required: true,
    },
    techName: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.techName"),
      layout: 12,
      required: true,
      disabled: true,
    },
    seriesCode: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.seriesCode"),
      layout: 12,
      required: true,
    },
    seriesName: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.seriesName"),
      layout: 12,
      required: true,
      disabled: true,
    },
    modelCode: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.modelCode"),
      layout: 12,
      required: false,
    },
    modelName: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.modelName"),
      layout: 12,
      required: false,
      disabled: true,
    },
    workCellCode: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.workCellCode"),
      layout: 12,
      required: true,
    },
    workCellName: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.workCellName"),
      layout: 12,
      required: true,
      disabled: true,
    },
    labelProperty: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.labelProperty"), //"关联动态属性列表",
      layout: 24,
      required: false,
    },
    characteristicList: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.characteristicList"),
      layout: 24,
      required: false,
    },
  },
};
//导入数据
export const importFormDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    model: {
      type: "button",
      label: "",//$i18n.t("mesTechnologyCharacteristic.model"),
      layout: 24,
      required: false,
      title: $i18n.t('common.downloadTemplate'),
      style: {
        color: "#1867c0",
        fontSize: "14px",
      },
      on: {
        click: () => {
          exportExcel(downloadTemplateUrl);
        },
      },
    },
    file: {
      type: "input",
      label: $i18n.t("mesTechnologyCharacteristic.file"),
      layout: 24,
      // required: true,
    },
  },
};
